<template>
  <div >
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图 -->
    <el-card class="scrolle scrollbar-sty">
      <el-table
        id="EditSelect"
        v-loading="tableLoading"
        tooltip-effect="dark"
        style="width: 100%"
        border
        stripe
        :data="tableData"
        :header-cell-style="{
          color: '#606266',
          textAlign: 'center',
        }"
        :cell-style="{ textAlign: 'center', padding: '5px 0', height: '30px' }"
        :row-style="{ height: '48px' }"
        empty-text="Current page has no data"
      >
        <el-table-column type="index" label="#"></el-table-column>
        <el-table-column
          prop="authName"
          label="权限名称"
          min-width="100"
        ></el-table-column>
        <el-table-column
          prop="path"
          label="路径"
          min-width="100"
        ></el-table-column>

        <el-table-column
          prop="level"
          label="权限等级"
          min-width="120"
        >
        <template slot-scope="scope">
            <el-tag v-if="scope.row.level == 0">一级</el-tag>
            <el-tag  type="success" v-else-if="scope.row.level == 1">二级</el-tag>
            <el-tag  type="warning" v-else-if="scope.row.level == 2">三级</el-tag>
        </template>
        </el-table-column>
      </el-table>

      <!-- 分页 -->
      <!-- <el-pagination
        background
        layout="total, sizes, prev, pager, next"
        :total="pageInfo.total"
        :page-sizes="[10, 20]"
        :page-size="pageInfo.pageSize"
        style="float: right"
        @current-change="changeCurrentPage"
        @size-change="changeSizePage"
      >
      </el-pagination> -->
    </el-card>
  </div>
</template>

<script>
export default {
  name: '',
  data() {
    return {
      pageInfo: {
        total: 0,
        pageSize: 10,
        currentPage: 1,
      },
      tableData: [],
      type: 'list',
      tableLoading: false,
    }
  },
  created() {
    this.getRightsList()
  },
  methods: {
    async getRightsList() {
      const { data: res } = await this.$http.get('rights/' + this.type)
      this.pageInfo.total = res.data.length
      this.tableData = res.data
      console.log(res.data)
    },
    // changeCurrentPage(val) {
    //   console.log(val)
    //   this.pageInfo.currentPage = val
    //   this.getRightsList()
    // },
    // changeSizePage(val) {
    //   this.pageInfo.pageSize = val
    //    this.getRightsList()
    // },
  },
}
</script>

<style lang="less" scoped>
.scrollbar-sty {
  height: calc(100vh - 90px);
  overflow-y: auto;
  overflow-x: hidden;
}
.input-with-select {
  width: 300px;
  margin-right: 20px;
}
.el-pagination {
  margin-top: 20px;
}
.search_input {
  width: 400px;
}
</style>
